package au.com.handsunited.model.invitations;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import au.com.handsunited.model.BaseEntity;
import au.com.handsunited.model.MotherOfAllEntities;

/**
 * @author arunda
 *
 */
public class Invitation extends MotherOfAllEntities implements
		Comparable<Invitation> {

	public static final String VALID_EMAILADDRESSES = "validEmailAddresses";
	public static final String INVALID_EMAILADDRESSES = "invalidEmailAddresses";

	public static final String INVITED_ENTITIES = "invitedEntities";
	public static final String INVITED_GROUPS = "invitedGroups";
	public static final String INVITED_ORGANISATIONS = "invitedOrganisations";
	public static final String INVITED_PROJECTS = "invitedProjects";
	public static final String INVITED_USERS = "invitedUsers";

	public static final String INVITEE_TYPE_GROUP = "group";
	public static final String INVITEE_TYPE_ORGANISATION = "organisation";
	public static final String INVITEE_TYPE_PROJECT = "project";
	public static final String INVITEE_TYPE_USER = "user";

	private BaseEntity from;
	private BaseEntity to;
	private BaseEntity invitee;
	private InvitationStatus status;
	private String message;

	private String nonMemberInviteeEmailAddress;
	private String nonMemberInviteeName;
	private String nonMemberInviteeContactName;
	private String nonMemberInviteeType; // user, organisation, project, group


	private static Logger logger = LoggerFactory.getLogger(Invitation.class);


	/**
	 *
	 */
	public Invitation() {
		super();
		status = InvitationStatus.INVITED;
	}


	/**
	 * @param from
	 * @param to
	 * @param invitee
	 * @param status
	 * @param message
	 */
	public Invitation(BaseEntity from, BaseEntity to, BaseEntity invitee,
			InvitationStatus status, String message) {
		this();
		this.from = from;
		this.to = to;
		this.invitee = invitee;
		this.status = status;
		this.message = message;
	}

	/**
	 * @param from
	 * @param nonMemberInviteeEmailAddress
	 * @param status
	 * @param message
	 * @param invitee
	 */
	public Invitation(BaseEntity from, BaseEntity to,
			String nonMemberInviteeEmailAddress, String nonMemberInviteeType,
			InvitationStatus status, String message) {
		this();
		this.from = from;
		this.to = to;
		this.nonMemberInviteeEmailAddress = nonMemberInviteeEmailAddress;
		this.nonMemberInviteeType = nonMemberInviteeType;
		this.status = status;
		this.message = message;
	}




	/**
	 * @param from
	 * @param nonMemberInviteeEmailAddress
	 * @param status
	 * @param message
	 */
	public Invitation(BaseEntity from, String nonMemberInviteeEmailAddress,
			String nonMemberInviteeType, InvitationStatus status, String message) {
		this();
		this.from = from;
		this.nonMemberInviteeEmailAddress = nonMemberInviteeEmailAddress;
		this.nonMemberInviteeType = nonMemberInviteeType;
		this.status = status;
		this.message = message;
	}


	/**
	 *
	 * @param from
	 * @param nonMemberInviteeName
	 * @param nonMemberInviteeEmailAddress
	 * @param nonMemberInviteeType
	 * @param status
	 * @param message
	 */
	public Invitation(BaseEntity from, String nonMemberInviteeName,
			String nonMemberInviteeEmailAddress, String nonMemberInviteeType,
			InvitationStatus status, String message) {
		this();
		this.from = from;
		this.nonMemberInviteeName = nonMemberInviteeName;
		this.nonMemberInviteeEmailAddress = nonMemberInviteeEmailAddress;
		this.nonMemberInviteeType = nonMemberInviteeType;
		this.status = status;
		this.message = message;
	}




	/**
	 * @param from
	 * @param nonMemberInviteeName
	 * @param nonMemberInviteeEmailAddress
	 * @param nonMemberInviteeContactName
	 * @param nonMemberInviteeType
	 * @param status
	 * @param message
	 */
	public Invitation(BaseEntity from, String nonMemberInviteeName,
			String nonMemberInviteeEmailAddress,
			String nonMemberInviteeContactName, String nonMemberInviteeType,
			InvitationStatus status, String message) {

		this();
		this.from = from;
		this.nonMemberInviteeName = nonMemberInviteeName;
		this.nonMemberInviteeEmailAddress = nonMemberInviteeEmailAddress;
		this.nonMemberInviteeContactName = nonMemberInviteeContactName;
		this.nonMemberInviteeType = nonMemberInviteeType;
		this.status = status;
		this.message = message;
	}


	/**
	 * @see au.com.handsunited.model.invitations.Invitation#getFrom()
	 */
	public BaseEntity getFrom() {
		return from;
	}


	/**
	 * @see au.com.handsunited.model.invitations.Invitation#getTo()
	 */
	public BaseEntity getTo() {
		return to;
	}

	/**
	 * @see au.com.handsunited.model.invitations.Invitation#getForEntity()
	 */
	public BaseEntity getForEntity() {
		return invitee;
	}


	/**
	 * @see au.com.handsunited.model.invitations.Invitation#getStatus()
	 */
	public InvitationStatus getStatus() {
		return status;
	}

	/**
	 * @see au.com.handsunited.model.invitations.Invitation#setStatus(au.com.handsunited.model.invitations.InvitationStatus)
	 */
	public void setStatus(InvitationStatus status) {
		this.status = status;
	}

	/**
	 * @see au.com.handsunited.model.invitations.Invitation#getMessage()
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * @see au.com.handsunited.model.invitations.Invitation#getNonMemberInviteeEmailAddress()
	 */
	public String getNonMemberInviteeEmailAddress() {
		return nonMemberInviteeEmailAddress;
	}


	/**
	 * @see au.com.handsunited.model.invitations.Invitation#getInvitee()
	 */
	public BaseEntity getInvitee() {
		return invitee;
	}


	/**
	 * @see au.com.handsunited.model.invitations.Invitation#getNonMemberInviteeName()
	 */
	public String getNonMemberInviteeName() {
		return nonMemberInviteeName;
	}


	/**
	 * @see au.com.handsunited.model.invitations.Invitation#getNonMemberInviteeContactName()
	 */
	public String getNonMemberInviteeContactName() {
		return nonMemberInviteeContactName;
	}


	/**
	 * @see au.com.handsunited.model.invitations.Invitation#getNonMemberInviteeType()
	 */
	public String getNonMemberInviteeType() {
		return nonMemberInviteeType;
	}


	/**
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
	 */
	@Override
	public int compareTo(Invitation invitation) {
		return getDateCreated().compareTo(invitation.getDateCreated());
	}



}

